home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue25 / survive / BUILDER1.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-07-20  |  1.6 KB  |  76 lines

  1. unit builder1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   DB, DBTables, StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Table1: TTable;
  12.     DataSource1: TDataSource;
  13.     DBGrid1: TDBGrid;
  14.     DBNavigator1: TDBNavigator;
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.DFM}
  29.  
  30. procedure TForm1.Button1Click(Sender: TObject);
  31. type
  32.   TTestRec = record
  33.       DelFlag: Byte;
  34.       EmpNo: SmallInt;
  35.       FirstName: string[15];
  36.       LastName: string[20];
  37.       HireDate: TDateTime;
  38.       DeptNo: string[3];
  39.       Salary: Double;
  40.     end;
  41. var
  42.   OutFile: file of TTestRec;
  43.   OutRec: TTestRec;
  44. begin
  45.   AssignFile(OutFile, 'Test1.Dat');
  46.   Rewrite(OutFile);
  47.   try
  48.     with Table1 do begin
  49.       Open;
  50.       try
  51.         while not Eof do begin
  52.           with OutRec do begin
  53.             DelFlag := 0;
  54.             EmpNo := FieldByName('Emp_No').AsInteger;
  55.             FirstName := FieldByName('First_Name').AsString;
  56.             LastName := FieldByName('Last_Name').AsString;
  57.             HireDate := FieldByName('Hire_Date').AsDateTime;
  58.             DeptNo := FieldByName('Dept_No').AsString;
  59.             Salary := FieldByName('Salary').AsFloat;
  60.           end;
  61.  
  62.           Write(OutFile, OutRec);
  63.  
  64.           Next;
  65.         end;
  66.       finally
  67.         Close;
  68.       end;
  69.     end;
  70.   finally
  71.     CloseFile(OutFile);
  72.   end;
  73. end;
  74.  
  75. end.
  76.